package com.wokeMy.view.adpter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wokeMy.view.model.RbZd;
import com.wokeMy.view.util.Util;
import com.zhongcai.online.R;

import java.util.ArrayList;


/**
 * Created by Administrator on 2017-11-22.
 */

public class RbRecordAdapter extends BaseAdapter {
    private LayoutInflater inflater;
    ArrayList<RbZd> ghtList=new ArrayList<>() ;
    Context context;
    int way_id;
    public RbRecordAdapter(Context context, ArrayList<RbZd> ghtList, int way_id) {
        this.inflater = LayoutInflater.from(context);
        this.ghtList=ghtList;
        this.context=context;
        this.way_id=way_id;
    }

    @Override
    public int getCount() {
        return ghtList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHold viewHold;
        if (convertView==null){
            viewHold=new ViewHold();
            convertView=inflater.inflate(R.layout.item_rc_lv,null);
            viewHold.tvTitle=(TextView)convertView.findViewById(R.id.rc_titlle);
            viewHold.tvTime=(TextView)convertView.findViewById(R.id.rc_time);
            viewHold.tvState=(TextView)convertView.findViewById(R.id.rc_state);
            convertView.setTag(viewHold);
        }else {
            viewHold=(ViewHold)convertView.getTag();
        }
        final RbZd ghtZd = ghtList.get(position);
        viewHold.tvTitle.setText("快捷 ("+ Util.twoString(ghtZd.getMoney())+")");
         String tip;
        switch (ghtZd.getStatus()) {
            case "2":
                tip="支付成功";
                break;
            case "1":
                tip="支付失败";
                break;
            default:
                tip="支付失败";
                break;
        }
        viewHold.tvState.setText(tip);
        viewHold.tvTime.setText(Util.getStrTi(ghtZd.getCreate_time()));
        Log.e("getView",way_id+"");
        return convertView;
    }
    class ViewHold{
        TextView tvTitle;
        TextView tvTime;
        TextView tvState;
    }
}
